package com.e3.sysmg.security.dao;

import java.util.List;

import com.e3.core.base.SuperDAO;
import com.e3.sysmg.security.entity.UserEntity;
import com.e3.sysmg.security.model.UserQC;

public class UserDAO extends SuperDAO {
	
	private String querySQL = "SELECT user FROM UserEntity user";
	
	public UserEntity getUserEntityByCode(String code){
		String whSql = " WHERE user.code=?";
		String sql = querySQL + whSql;
		List<UserEntity> entities = this.find(sql, code);
		return (entities == null||entities.size()==0)?null:entities.get(0);
	}
	
	public List<UserEntity> getUserByCondition(UserQC qc){
		String sql = querySQL;
		qc.setPrefix("user");
		String whereSQL = qc.getWhereSQL();
		if(whereSQL!=null&&whereSQL.length()>0){
			sql = sql + " WHERE " +whereSQL;
		}
		return this.find(sql);
	}
}
